<%--
  Created by IntelliJ IDEA.
  User: 86137
  Date: 2021/8/2
  Time: 19:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>update</title>

    <script src="validate/jquery-1.11.0.min.js"></script>
    <script src="validate/jquery.validator.min.js"></script>
    <script src="validate/local/zh-CN.js"></script>
    <link href="validate/jquery.validator.css" rel="stylesheet">
    <%--异步获取现居地--%>
    <script src="js/jquery-3.3.1.min.js"></script>




    <%--使用异步获取居住地--%>
    <script>
        //页面加载事件
        $(function () {
            //发送异步请求到服务器   [{"id":1,"name":"北京市"},{"id":2,"name":"上海市"}]
            $.post("provinceServlet",{},function (data) {
                //浏览器端遍历JSON数组, 生成多个<option>标签, 添加到<select>内部的后面
                $(data).each(function () {
                    $("#xzd").append("<option value='"+this.name+" ${u.address=='"+this.name+"'?"selected":""}'>"+this.name+"</option>");
                });
            },"json");
        })

    </script>






</head>
<body>
        <form action="${pageContext.request.contextPath}/userServlet?method=update" method="post">
                <input type="hidden" name="id" value="${u.id}">
            <label for="name">姓名:</label>
            <input type="text" name="name" id="name" value="${u.name}" data-rule="姓名:required;length[2~10]"  /><br>
            <label>性别:</label>
            <input type="radio" name="gender" value="男" ${u.gender=='男'?"checked":""}  />男
            <input type="radio" name="gender" value="女" ${u.gender=='女'?"checked":""} />女<br>
            <label for="age">年龄:</label>
            <input type="number" name="age" id="age" value="${u.age}" data-rule="年龄:required;range[1~150]"  /><br>
            <label for="xzd">现居地:</label>
            <select name="address" id="xzd">

            </select><br>
            <label for="qq">QQ:</label>
            <input type="number" name="qq" id="qq" value="${u.qq}" data-rule="QQ:required" /><br>
            <label for="email">邮箱:</label>
            <input type="email" name="email" id="email" value="${u.email}" data-rule="email:required" /><br>
            <button type="submit">修改</button>&nbsp;
            <button type="button" onclick="history.go(-1)">返回</button><br>
        </form>
</body>
</html>
